package com.ruoyi.web.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.mapper.JapanExaminationTdkMapper;
import com.ruoyi.web.domain.JapanExaminationTdk;
import com.ruoyi.web.service.IJapanExaminationTdkService;
import com.ruoyi.common.core.text.Convert;

/**
 * 日本体检TDK配置Service业务层处理
 * 
 * @author drx
 * @date 2025-05-19
 */
@Service
public class JapanExaminationTdkServiceImpl implements IJapanExaminationTdkService 
{
    @Autowired
    private JapanExaminationTdkMapper japanExaminationTdkMapper;

    /**
     * 查询日本体检TDK配置
     * 
     * @param id 日本体检TDK配置主键
     * @return 日本体检TDK配置
     */
    @Override
    public JapanExaminationTdk selectJapanExaminationTdkById(Long id)
    {
        return japanExaminationTdkMapper.selectJapanExaminationTdkById(id);
    }

    /**
     * 查询日本体检TDK配置列表
     * 
     * @param japanExaminationTdk 日本体检TDK配置
     * @return 日本体检TDK配置
     */
    @Override
    public List<JapanExaminationTdk> selectJapanExaminationTdkList(JapanExaminationTdk japanExaminationTdk)
    {
        return japanExaminationTdkMapper.selectJapanExaminationTdkList(japanExaminationTdk);
    }

    /**
     * 新增日本体检TDK配置
     * 
     * @param japanExaminationTdk 日本体检TDK配置
     * @return 结果
     */
    @Override
    public int insertJapanExaminationTdk(JapanExaminationTdk japanExaminationTdk)
    {
        japanExaminationTdk.setCreateTime(DateUtils.getNowDate());
        japanExaminationTdk.setCreateBy(ShiroUtils.getSysUser().getLoginName());
        japanExaminationTdk.setCreateName(ShiroUtils.getSysUser().getUserName());

        japanExaminationTdk.setUpdateTime(DateUtils.getNowDate());
        japanExaminationTdk.setUpdateBy(ShiroUtils.getSysUser().getLoginName());
        japanExaminationTdk.setUpdateName(ShiroUtils.getSysUser().getUserName());
        return japanExaminationTdkMapper.insertJapanExaminationTdk(japanExaminationTdk);
    }

    /**
     * 修改日本体检TDK配置
     * 
     * @param japanExaminationTdk 日本体检TDK配置
     * @return 结果
     */
    @Override
    public int updateJapanExaminationTdk(JapanExaminationTdk japanExaminationTdk)
    {
        japanExaminationTdk.setUpdateTime(DateUtils.getNowDate());
        japanExaminationTdk.setUpdateBy(ShiroUtils.getSysUser().getLoginName());
        japanExaminationTdk.setUpdateName(ShiroUtils.getSysUser().getUserName());
        return japanExaminationTdkMapper.updateJapanExaminationTdk(japanExaminationTdk);
    }

    /**
     * 批量删除日本体检TDK配置
     * 
     * @param ids 需要删除的日本体检TDK配置主键
     * @return 结果
     */
    @Override
    public int deleteJapanExaminationTdkByIds(String ids)
    {
        return japanExaminationTdkMapper.deleteJapanExaminationTdkByIds(Convert.toStrArray(ids),ShiroUtils.getSysUser().getLoginName());
    }

    /**
     * 删除日本体检TDK配置信息
     * 
     * @param id 日本体检TDK配置主键
     * @return 结果
     */
    @Override
    public int deleteJapanExaminationTdkById(Long id)
    {
        return japanExaminationTdkMapper.deleteJapanExaminationTdkById(id,ShiroUtils.getSysUser().getLoginName());
    }

    @Override
    public AjaxResult editExaminationTdkSet(List<JapanExaminationTdk> list){
        AjaxResult ajaxResult = new AjaxResult();
        try {
            list.forEach(bean->{
                this.updateJapanExaminationTdk(bean);
            });
            ajaxResult.put("code","1");
            ajaxResult.put("msg","操作成功！");
        }catch (Exception e){
            e.printStackTrace();
            ajaxResult.put("code","500");
            ajaxResult.put("msg","操作失败，请联系管理员！");
        }
        return ajaxResult;
    }
}
